package fr.afcepf.ai89.esharing.entity;

import java.io.Serializable;
import javax.persistence.*;
import java.util.List;


/**
 * The persistent class for the fr_code_postal_asso database table.
 * 
 */
@Entity
@Table(name="fr_code_postal_asso")
@NamedQuery(name="FrCodePostalAsso.findAll", query="SELECT f FROM FrCodePostalAsso f")
public class FrCodePostalAsso implements Serializable {
	private static final long serialVersionUID = 1L;

	@EmbeddedId
	private FrCodePostalAssoPK id;

	//bi-directional many-to-one association to FrCommune
	@ManyToOne
	@JoinColumns({
		@JoinColumn(name="CODE_COMMUNE", referencedColumnName="CODE_COMMUNE", insertable=false, updatable=false),
		@JoinColumn(name="ID_DEPT_COM", referencedColumnName="ID_DEPARTEMENT", insertable=false, updatable=false)
		})
	private FrCommune frCommune;

	//bi-directional many-to-one association to Proprietaire
	@OneToMany(mappedBy="frCodePostalCommune")
	private List<Proprietaire> proprietaires;

	public FrCodePostalAsso() {
	}

	public FrCodePostalAssoPK getId() {
		return this.id;
	}

	public void setId(FrCodePostalAssoPK id) {
		this.id = id;
	}

	public FrCommune getFrCommune() {
		return this.frCommune;
	}

	public void setFrCommune(FrCommune frCommune) {
		this.frCommune = frCommune;
	}

	public List<Proprietaire> getProprietaires() {
		return this.proprietaires;
	}

	public void setProprietaires(List<Proprietaire> proprietaires) {
		this.proprietaires = proprietaires;
	}

	public Proprietaire addProprietaire(Proprietaire proprietaire) {
		getProprietaires().add(proprietaire);
		proprietaire.setFrCodePostalCommune(this);

		return proprietaire;
	}

	public Proprietaire removeProprietaire(Proprietaire proprietaire) {
		getProprietaires().remove(proprietaire);
		proprietaire.setFrCodePostalCommune(null);

		return proprietaire;
	}

}